import request from "@/utils/request";
import qs from "qs";
import { Base64 } from "js-base64";
import {
  getCode_,
  pwoLogin_,
  pwoLogin2_,
  phoneVerCode_,
  logMassg_,
  wxLogout_,
} from "./urlApi";
// 登录方法
export function login(userName, password, code, status, phone, verification) {
  let data = {
    phone: userName,
    pwd: password,
    volide: code,
  };
  let urlData = pwoLogin_;

  if (status == 2) {
    urlData = pwoLogin2_;
    data = {
      phone: phone,
      checkCode: verification,
    };
  }
  return request({
    url: urlData,
    headers: {
      isToken: false,
    },
    method: "post",
    data: qs.stringify(data),
  });
}

// 获取用户详细信息
export function phoneVerCode(data) {
  return request({
    url: phoneVerCode_,
    method: "get",
    params: data,
  });
}

// 获取用户详细信息
export function getInfo(data) {
  return request({
    url: logMassg_,
    method: "post",
    data: qs.stringify(data),
  });
}

export function register() {
  return request({
    url: wxLogout_,
    // headers: {
    //   "Content-Type": "application/json;charset=utf-8",
    // },
    method: "get",
  });
}
// 退出方法
export function logout() {
  return request({
    // headers: {
    //   "Content-Type": "application/json;charset=utf-8",
    // },
    url: wxLogout_,
    method: "get",
  });
}
// 获取验证码
export function getCodeImg(time) {
  return request({
    url: getCode_,
    method: "post",
    responseType: "blob",
    data: qs.stringify(time),
  });
}
